package fr.unice.polytech.chord.core.messages.asynchronous;

import fr.unice.polytech.chord.core.ChordNode;
import fr.unice.polytech.chord.core.Entry;
import fr.unice.polytech.chord.core.responses.asynchronous.ActionResponseMessage;
import fr.unice.polytech.chord.core.responses.asynchronous.AsynchronousResponseMessage;

/**
 * Add a new entry to the {@link ChordNode} which handles this message.
 * 
 * @author Anthony Parisy
 * @author Laurent Pellegrino
 * @author Marc Valdener
 * 
 * @version 10/28/2009
 */
@SuppressWarnings("serial")
public class AddEntryMessage extends AsynchronousMessage {

	private Entry<String> entry;

	/**
	 * Constructor.
	 * 
	 * @param entry
	 *            the entry to add.
	 */
	public AddEntryMessage(Entry<String> entry) {
		this.entry = entry;
	}

	/**
	 * {@inheritDoc}
	 */
	@Override
	public AsynchronousResponseMessage handle(ChordNode node) {
		return new ActionResponseMessage(node.addEntry(entry));
	}
}
